package no.ntnu.fp.testing;

import static org.junit.Assert.*;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import no.ntnu.fp.model.SimpleEcu;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SimpleEcuTest {
	SimpleEcu se;
	private int ecuId;
	private int swId;
	PropertyChangeSupport pcs;

	@Before
	public void setUp() throws Exception {		
		se = new SimpleEcu();
		pcs= new PropertyChangeSupport(ecuId);
		se= new SimpleEcu(ecuId);
		se= new SimpleEcu(ecuId,swId);
		se.addPropertyChangeListener((PropertyChangeListener) this);		
	}	

	@After
	public void tearDown() throws Exception {
		se.removePropertyChangeListener((PropertyChangeListener) this);
	}
	

	@Test
	public void testSimpleEcuInt() {
		se= new SimpleEcu(ecuId);
		assertTrue(se instanceof SimpleEcu);
		
	}

	@Test
	public void testSimpleEcu() {
		se= new SimpleEcu();
		assertTrue(se instanceof SimpleEcu);
	}

	@Test
	public void testSimpleEcuIntInt() {
		se= new SimpleEcu(ecuId, swId);
		assertTrue(se instanceof SimpleEcu);
	}

	@Test
	public void testAddPropertyChangeListener() {
		se.addPropertyChangeListener((PropertyChangeListener) this);
		assertTrue(pcs.getPropertyChangeListeners()!=null);
	}

	@Test
	public void testRemovePropertyChangeListener() {
		se.removePropertyChangeListener((PropertyChangeListener) this);
		assertTrue(pcs.getPropertyChangeListeners()==null);
		}

	@Test
	public void testGetEcuId() {
		se.setEcuId(2);
		assertTrue(se.getEcuId()==2);
	}

	@Test
	public void testSetEcuId() {
		se.setEcuId(5);
		assertEquals(se.getEcuId(),5);
	}

	@Test
	public void testGetSwId() {
		se.setSwId(3);
		se.setEcuId(2);
		assertTrue(se.getEcuId()==3&&se.getSwId()==2);
	}

	@Test
	public void testSetSwId() {
		//fail("Not yet implemented");
	}

	@Test
	public void testEquals() {
		//fail("Not yet implemented");
	}

}
